from PIL import Image, ImageDraw, ImageFont
import os

def create_icon():
    # 创建一个512x512的图像，使用RGBA模式支持透明度
    size = 512
    image = Image.new('RGBA', (size, size), (0, 0, 0, 0))
    draw = ImageDraw.Draw(image)
    
    # 绘制圆形背景
    circle_color = (41, 128, 185)  # 蓝色
    draw.ellipse([(0, 0), (size, size)], fill=circle_color)
    
    # 绘制文件图标
    file_color = (255, 255, 255)  # 白色
    file_width = size * 0.6
    file_height = size * 0.8
    file_x = (size - file_width) / 2
    file_y = (size - file_height) / 2
    
    # 绘制文件主体
    draw.rectangle(
        [(file_x, file_y), (file_x + file_width, file_y + file_height)],
        fill=file_color,
        outline=file_color
    )
    
    # 绘制文件折角
    fold_size = file_width * 0.2
    draw.polygon(
        [
            (file_x + file_width - fold_size, file_y),
            (file_x + file_width, file_y),
            (file_x + file_width, file_y + fold_size)
        ],
        fill=circle_color
    )
    
    # 绘制统计符号
    symbol_color = (41, 128, 185)  # 蓝色
    symbol_size = file_width * 0.4
    symbol_x = file_x + (file_width - symbol_size) / 2
    symbol_y = file_y + (file_height - symbol_size) / 2
    
    # 绘制"#"符号
    line_width = symbol_size * 0.1
    draw.rectangle(
        [(symbol_x, symbol_y), (symbol_x + symbol_size, symbol_y + line_width)],
        fill=symbol_color
    )
    draw.rectangle(
        [(symbol_x, symbol_y + symbol_size - line_width),
         (symbol_x + symbol_size, symbol_y + symbol_size)],
        fill=symbol_color
    )
    draw.rectangle(
        [(symbol_x, symbol_y), (symbol_x + line_width, symbol_y + symbol_size)],
        fill=symbol_color
    )
    draw.rectangle(
        [(symbol_x + symbol_size - line_width, symbol_y),
         (symbol_x + symbol_size, symbol_y + symbol_size)],
        fill=symbol_color
    )
    
    # 保存为ICO文件
    icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icon.ico')
    image.save(icon_path, format='ICO', sizes=[(256, 256), (128, 128), (64, 64), (32, 32), (16, 16)])
    print(f"图标已保存到: {icon_path}")

if __name__ == '__main__':
    create_icon() 